<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <table id="smapleTable">
        <tr>
            <td>Row1 Cell1</td>
            <td>Row1 Cell2</td>
        </tr>
        <tr>
            <td>Row2 Cell1</td>
            <td>Row2 Cell2</td>
        </tr>
    </table>
    <input type="button" value="插入行" id="insertrow">
    <script>
        document.querySelector("#insertrow").onclick=function(e){
            var tableObj=document.querySelector("#smapleTable");
            //创建元素
            var trObj=document.createElement("tr");
            var tdObj1=document.createElement("td");
            var tdObj2=document.createElement("td");
            var textObj1=document.createTextNode("hello");
            var textObj2=document.createTextNode("world");
            tdObj1.appendChild(textObj1);
            tdObj2.appendChild(textObj2);
            trObj.appendChild(tdObj1);
            trObj.appendChild(tdObj2);
            tableObj.appendChild(trObj);
        }
    </script>
</body>
</html>